#ifndef FOCUSWIDGET_H
#define FOCUSWIDGET_H

#include <QWidget>
#include "TimelineChart.h"
#include <QLabel>
#include <QTextEdit>

class FocusWidget : public QWidget
{
    Q_OBJECT
public:
    explicit FocusWidget(QWidget *parent = nullptr);
    virtual ~FocusWidget();
public:
    void setThemeName(const QString& name);
    // 添加一个事件
    void addEvent(const QString& event);

    // 批量添加事件
    void addEvents(const QVector<QString>& events);

    // 设置倒计时时间，单位为毫秒
    void setCountdown(int milliseconds);

    // 设置窗口尺寸
    void setWindowSize(int width, int height);

    void setStartDataTime();

    void setStopDataTime();
protected:
    virtual void mouseMoveEvent(QMouseEvent *event) override;
    virtual void mousePressEvent(QMouseEvent *event) override;
    virtual void mouseReleaseEvent(QMouseEvent * event) override;
private:
    void initForm();
    void initData();
    // 初始化布局
    void initializeLayout();
    // 函数：生成时间范围字符串
    QString generateTimeRangeString();

    void updateTimeLabel(const QString& str);
private slots:
    void onConfirmBtnClick();
private:
    TimelineChart* m_pChart;
    QLabel* m_pTitleLbl;
    QLabel* m_pTargetLbl;
    QLabel* m_pTimeLbl;
    QTextEdit* m_pContntEdit;
    QPushButton* m_pConfirmBtn;
    bool isDragging;

    QPoint mouse_startPoint;
    QPoint window_top_left_point;
    QWidget* mainWidget;
private:
    int m_nMilliseconds;
    QString  m_strThemeName;
    QDateTime m_startTime;      // 开始时间，用于倒计时计算
    QDateTime m_stopTime;      // 开始时间，用于倒计时计算
};

#endif // FOCUSWIDGET_H
